import java.util.Scanner;

public class Test09ATM {
    static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        String[] userArr = {"zhangsan", "lisi"};
        String[] passwordArr = {"123", "456"};
        double[] accountArr = {500, 1000};

        int index = login(userArr, passwordArr); // 当前登录人下标
//        accountArr[index]; // 1000

        if (index >= 0) {
            System.out.println("欢迎" + userArr[index]);

            System.out.println("1 存 2 取 3 查 4 退：");
            int opt = scan.nextInt();
            switch (opt) {
                case 1:
                    add(accountArr, index); // 存款
                    break;
                case 2:
                    // 取款
                    break;
                case 3:
                    System.out.println("余额：" + accountArr[index]);
                    break;
                case 4:
                    System.out.println("886");
                    break;
            }

        } else {
            System.out.println("查无此人");
        }
    }

    // 存款
    public static void add(double[] accountArr, int i) {
        System.out.println("请输入存款金额：");
        int money = scan.nextInt(); // 100
        accountArr[i] += money;
    }

    // 登录
    public static int login(String[] userArr, String[] passwordArr) {
        System.out.println("请输入账号：");
        String iptUsername = scan.next();
        System.out.println("请输入密码：");
        String iptPassword = scan.next();

        // 判定
        for (int i = 0; i < userArr.length; i++) {
            if (userArr[i].equals(iptUsername) && passwordArr[i].equals(iptPassword)) { // 登录成功
                return i; // 登录人的下标
            }
        }
        return -1;
    }


}
